/*
 * 新下发任务(m:n)
 * */
 Ext.define('MobileTest.view.window.NewMobileTaskWindow',{
 	extend:'Ext.window.Window', 	
 	width:800,
 	height:500,
 	modal:true,
 	title:'新建下发任务', 	
	initComponent : function() {
		
		var me = this;
		
		var tvstore = Ext.create('Ext.data.TreeStore', {
   			 root: {
        	 expanded: true,
        	children: [
            { text: "detention", leaf: true },
            { text: "homework", expanded: true, children: [
                { text: "book report", leaf: true },
                { text: "alegrbra", leaf: true}
            ] },
            { text: "buy lottery tickets", leaf: true }
        	]
    	}
		});
		
	var gridstore=	Ext.create('Ext.data.Store', {
    	//storeId:'simpsonsStore',
    	fields:['name', 'email', 'phone'],
    	data:{'items':[
        	{ 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224"  },
        	{ 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234" },
        	{ 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244"  },
        	{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254"  }
    	]},
    	proxy: {
        	type: 'memory',
        	reader: {
            	type: 'json',
            	root: 'items'
        	}
    	}
	});
		
		Ext.applyIf(me, {
			layout:'border',  
			items:[			
				{
					xtype:'treepanel',
					region:'west',
					title: '终端',
    				width: 200,
    				//height: 150,
    				store: tvstore,
    				rootVisible: false
				},{
					xtype:'gridpanel',
					region:'center',
					title: '任务模版',
    				store: gridstore,
    				columns: [
        				{ header: '模版',  dataIndex: 'name' , flex: 1 },
        				{ header: 'Email', dataIndex: 'email'},
        				{ header: 'Phone', dataIndex: 'phone' }
    				],
    				dockedItems : [ {
					xtype : 'toolbar',
					dock : 'top',
					items : [{	
							xtype    : 'textfield',
				            name     : 'txt_search_key',
				            emptyText: '请输入要查询号码'
				        },{				          
				            text: '检索',
				            tooltip : '检索查询号码',						
							iconCls : 'search',
				            handler : function() {
								
				            	var key=this.up('toolbar').child('textfield').getValue();
				            	
				               	me.store.load({params:{mobile:key}});
				            }
				        } ]}
				        ,{
			        		xtype: 'pagingtoolbar',
			        		store: gridstore,   
			        		dock: 'bottom',
			        		displayInfo: true
			    		}
				    ]
				}
			],
 			dockedItems:[ {
					xtype : 'toolbar',
					dock : 'top',
					items : [ {
							text : '保存',
							tooltip : '保存添加测试任务',
							iconCls : 'add',
							handler : function() {
							
							}
						}, {
							text : '关闭',
							tooltip : '关闭窗口',
							iconCls : 'add',
							handler : function() {
									me.close();
							}
					}]
			}]
		});
		me.callParent(arguments);	
	}
	
 });
 